
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="distributorSalesSearch.do"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,java.util.Calendar,java.util.ArrayList,
                        com.scalar.chiptrack.utils.StringUtils"%>
<%@ page import="com.scalar.chiptrack.commons.Constants" %>
<%
    String chipTracContext = "/" + ConfigManager.getChipTracContext();
    String userTypeChiptrac = Constants.USER_TYPE_CHIPTRAC + "";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>

<SCRIPT language="JavaScript">
var defaultYear;
<%
	Calendar cl   = Calendar.getInstance();
%>
	defaultYear = <%=cl.get( Calendar.YEAR )%>

function searchDistributorSales()
{
    document.distributorSearchForm.action	= "<%=chipTracContext%>/distributorSalesSearch.do?action=search";
    document.distributorSearchForm.submit();
    return true;
}

function generateDistributorSales()
{
    document.distributorSearchForm.action	= "<%=chipTracContext%>/distributorSales.do?action=create";
    document.distributorSearchForm.submit();
}

function viewDistributorSales(distSalesOrderId)
{
    document.distributorSearchForm.action = "<%=chipTracContext%>/distributorSales.do?action=view&distributorSalesOrder=view&distSalesOrderId=" + distSalesOrderId;
    document.distributorSearchForm.submit();
}
function modifyDistributorSales(distSalesOrderId)
{
    document.distributorSearchForm.action = "<%=chipTracContext%>/distributorSales.do?action=modify&distSalesOrderId=" + distSalesOrderId;
    document.distributorSearchForm.submit();
}
function cancelDistributorSales(distSalesOrderId)
{
    document.distributorSearchForm.action = "<%=chipTracContext%>/distributorSales.do?action=view&distributorSalesOrder=cancel&distSalesOrderId=" + distSalesOrderId;
    document.distributorSearchForm.submit();
}

function closeDistributorSales(distSalesOrderId)
{
    document.distributorSearchForm.action = "<%=chipTracContext%>/distributorSales.do?action=view&distributorSalesOrder=close&distSalesOrderId=" + distSalesOrderId;
    document.distributorSearchForm.submit();
}


</SCRIPT>

<!-- Top Header Start-->

<%@ include file="/jsp/includes/header.jsp" %>

<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
	<TBODY>
	<TR>
		<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
        <!-- Side Navigation start -->
		<%--<%@ include file="/jsp/operations/operations_menu.jsp" %>--%>
        <logic:equal value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/operations/operations_menu.jsp" %>
        </logic:equal>
        <logic:notEqual value="<%=userTypeChiptrac%>" name="user" property="userType" scope="session">
            <%@ include file="/jsp/admin/externaluser_menu.jsp" %>
        </logic:notEqual>
        <!-- end of the side navigations -->
		</td>
		<td bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=10></td>
		<td valign="top" width="100%">
			<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0><BR>
            <!-- from here your body starts -->
			<html:form name="distributorSearchForm" method="post" action="/distributorSalesSearch" type="com.scalar.chiptrack.operations.distributor.forms.DistributorSearchForm" onsubmit="javascript:return searchDistributorSales();" >
			<center><span class="NArialW">Distributor Sales</span></center><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
			<table border="0" width="100%" align=right >
				<tr>
					<td>
						<table border="0" width="100%" align=right>
						<tr><td colspan=6 class="NArialL" align="left"><font color="FF0000"><FONT id="errors"></FONT></font></td></tr>
						<tr><td colspan=6 id="svrErrors"><chiptrack:errors styleClass="NArialL"/></td></tr>
						<tr><td colspan=6 id="svrInfo"><chiptrack:info styleClass="NArialL"/></td></tr>
						<tr><td colspan=6><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
						<tr>
                            <td width="10%">&nbsp;</td>
							<td width="15%" ALIGN="RIGHT" class="NArialL">Distributor Name</td>
							<td width="20%"><font class="NArialL">
								<html:select name="distributorSearchForm"  property="distributorId" styleClass="txfield">
                                    <html:option value="0">All Distributor</html:option>
                                    <html:options collection="distributorList" property="value" labelProperty="label"/>
								</html:select>
							</td>
                            <td width="15%" ALIGN="RIGHT" class="NArialL"><bean:message key="label.sales.shipToCustomer"/></td>
							<td width="20%" class="NArialL">
								<html:select name="distributorSearchForm"  property="customerId" styleClass="txfield">
                                    <html:option value="0">All <bean:message key="label.sales.shipToCustomer"/></html:option>
                                    <html:options collection="searchCustomerList" property="value" labelProperty="label"/>
								</html:select>
							</td>
                            <td width="20%">&nbsp;</td>
						</tr>
						<tr>
                            <td width="10%">&nbsp;</td>
							<td width="15%" class="NArialL" align="right">Product Name</td>
							<td width="20%" class="NArialL">
                                <html:select name="distributorSearchForm" property="manufacturingPartNo" styleClass="txfield">
                                    <html:options collection="productList" property="value" labelProperty="label"/>
                                </html:select>
							</td>
                            <td width="15%" class="NArialL" ALIGN="RIGHT">Year</td>
							<td width="20%" class="NArialL">
								<html:select name="distributorSearchForm"  property="year" styleClass="txfield">
									<html:option value="0">--All--</html:option>
									<html:options collection="yearList" property="value" labelProperty="label" />
								</html:select>
							</td>
                            <td width="20%">&nbsp;</td>
						</tr>
						<tr><td colspan='6'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
						<tr>
							<td colspan="6" align="center">
								<input type=image border="0" src="<%=chipTracContext%>/jsp/includes/images/search.gif" width="53" height="17" onmouseover="window.status='Click to Search for Distributor Sales';return true" onmouseout="window.status='';return true" title="Click to Search for Distributor Sales">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<a href="javascript:document.distributorSearchForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
							</td>
						</tr>
                        <tr><td colspan="6" align=left  class="NArialL">Click here to <a href="javascript:generateDistributorSales();"onmouseover="window.status='Click to Generate New Distributor Sale';return true" onmouseout="window.status='';return true">Generate</a> Distributor Sales </td> </tr>
						</table>
					</td>
				</tr>
                
				<tr>
					<td>
						<%
							ArrayList salesOrderList = (ArrayList)request.getAttribute( "searchList" );
							if( salesOrderList != null && salesOrderList.size() > 0 )
							{
						%>
						<table border="0" width="100%" align=right cellpadding="2" cellspacing="2">
							<tr>
								<td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Sales Order #</font></font></td>
                                <td width="25%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Distributor</font></font></td>
                                <td width="20%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.shipToCustomer"/></font></font></td>
								<td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Customer PO #</font></font></td>
                                <td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Status</font></font></td>
								<td width="10%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Ship Date</font></font></td>
                                <td colspan="4" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Actions</font></font></td>
                            </tr>
							<logic:iterate id="SalesOrder" name="searchList" indexId="iteratorIdx">
							<tr <%if(iteratorIdx.intValue()%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%> >
                                <td class="NArialL" align="center">
                                    <a href="javascript:viewDistributorSales('<bean:write name="SalesOrder" property="salesOrderId"/>');"onmouseover="window.status='Click to View';return true" onmouseout="window.status='';return true"><bean:write name="SalesOrder" property="salesOrder"/></a>
                                </td>
                                <td class="NArialL"><bean:write name="SalesOrder" property="distributor"/></td>
								<td class="NArialL"><bean:write name="SalesOrder" property="customer"/></td>
								<td class="NArialL" align="center"><bean:write name="SalesOrder" property="customerPo"/></td>
                                <td class="NArialL" align="center"><bean:write name="SalesOrder" property="status"/></td>
                                <td class="NArialL" align="center"><bean:write name="SalesOrder" property="shipDate"/>&nbsp;</td>
                                <td align="center"><a href="javascript:viewDistributorSales('<bean:write name="SalesOrder" property="salesOrderId"/>');" class="leftsection" onmouseover="window.status='Click here to view Distributor Sales Order';return true" onmouseout="window.status='';return true">View</a></td>
                                <td align="center">
                                    <logic:equal value="OPEN" name="SalesOrder" property="status">
                                        <a href="javascript:modifyDistributorSales('<bean:write name="SalesOrder" property="salesOrderId"/>');" class="leftsection" onmouseover="window.status='Click here to view Distributor Sales Order';return true" onmouseout="window.status='';return true">Modify</a>
                                    </logic:equal>
                                    <logic:notEqual value="OPEN" name="SalesOrder" property="status">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </logic:notEqual>
                                    <%--<logic:notEqual value="" name="SalesOrder" property="status">
                                        <%--<chiptrack:restrictedLink functionality='<%=Functionality.CREDIT_DEBIT_NOTE %>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href='<%=chipTracContext+"/creditNoteAction.do?action="+Constants.ACTION_MODIFY+ "&creditNoteId=" %>'
                                            onmouseover="window.status='Click here to modify Distributor Sales Order';return true" onmouseout="window.status='';return true">Modify</chiptrack:restrictedLink>--%><%--
                                        <a href="javascript:viewDistributorSales('<bean:write name="SalesOrder" property="salesOrderId"/>');" class="leftsection" onmouseover="window.status='Click here to view Distributor Sales Order';return true" onmouseout="window.status='';return true">Modify</a>
                                    </logic:notEqual>--%>
                                </td>
                                <td align="center">
                                    <logic:equal value="OPEN" name="SalesOrder" property="status">
                                        <a href="javascript:cancelDistributorSales('<bean:write name="SalesOrder" property="salesOrderId"/>');" class="leftsection" onmouseover="window.status='Click here to cancel Distributor Sales Order';return true" onmouseout="window.status='';return true">Cancel</a>
                                    </logic:equal>
                                    <logic:notEqual value="OPEN" name="SalesOrder" property="status">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </logic:notEqual>
                                        <%--<logic:notEqual value="cancel" name="SalesOrder" property="status">
                                        --%><%--<chiptrack:restrictedLink functionality='<%=Functionality.APPROVE_CREDIT_DEBIT_NOTE %>' action='<%=User.USER_ACTION_MODIFY%>' styleClass="leftsection" href='<%=chipTracContext+"/creditNoteAction.do?action="+Constants.ACTION_APPROVED+ "&creditNoteId=" %>'
                                            onmouseover="window.status='Click here to Cancel Distributor Sales Order';return true" onmouseout="window.status='';return true">Cancel</chiptrack:restrictedLink>--%><%--
                                        <a href="javascript:viewDistributorSales('<bean:write name="SalesOrder" property="salesOrderId"/>');" class="leftsection" onmouseover="window.status='Click here to view Distributor Sales Order';return true" onmouseout="window.status='';return true">Cancel</a>
                                    </logic:notEqual>--%>
                                </td>
                                <td align="center">
                                    <logic:equal value="OPEN" name="SalesOrder" property="status">
                                        <a href="javascript:closeDistributorSales('<bean:write name="SalesOrder" property="salesOrderId"/>');" class="leftsection" onmouseover="window.status='Click here to Close Distributor Sales Order';return true" onmouseout="window.status='';return true">Close</a>
                                    </logic:equal>
                                    <logic:notEqual value="open" name="SalesOrder" property="status">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </logic:notEqual>
                                </td>
                            </tr>
							</logic:iterate>
						</table>
						<%
							}
						%>
						<!-- / logic : equal -->
					</td>
				</tr>
			</table>
			</html:form>
<!-- body ends here -->
		</td>
	</tr>
	</tbody>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>

<!-- footer end here -->

</BODY>
</HTML>
